using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.TestDrivens;
using Pixysoft.Framework.Configurations;

namespace Pixysoft.Framework.Configurations.TestCases
{
    [TestDriven(TestDrivenType.IntegrationTest, "XmlManager")]
    class UnitTest_026_XmlManager
    {
        static IAssert assert = Assert.New();

        [TestStart]
        public static bool TestCaseStart()
        {

            return true;
        }

        [TestStop]
        public static void TestCaseStop()
        {
        }

        [TestStateSave]
        public static ITestDrivenDocument TestCaseStateSave()
        {
            return assert.Document;
        }

        [TestCase("Serialize")]
        public static void TestCase_007_Serialize()
        {
            Helloworld world = new Helloworld();
            world.Name = "hello";
            world.Age = 12;
            world.List.Add(new World());

            IXmlNode node = XmlManager.Serialize(world);
            assert.IsNotNull(node);

            string content = node.Serialize();
            assert.Write(content);

            node = XmlManager.Deserialize(content);
            assert.IsNotNull(node);

            world = XmlManager.Deserialize<Helloworld>(content);
            assert.IsNotNull(world);
            assert.IsNotNull(world.List);
            assert.IsEqual(1, world.List.Count);
            assert.IsEqual("hello", world.Name);
        }

    }

    class Helloworld
    {
        string name;
        int age;

        List<World> list = new List<World>();
        public string Name
        {
            get { return name; }
            set { name = value; }
        }
        public int Age
        {
            get { return age; }
            set { age = value; }
        }
        public List<World> List
        {
            get { return list; }
            set { list = value; }
        }

    }

    class World
    {
        string name;
        public string Name
        {
            get { return name; }
            set { name = value; }
        }
    }
}
